﻿@{
    Layout = null;
}
@model ElingOA6_Admin_DSJCJ.Model.FTP_New
@{
    int documentCount = ViewData["documentCount"] == null ? 0 : int.Parse(ViewData["documentCount"].ToString());//相关类别的信息条数
}
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>信息类别编辑</title>
    @Html.Partial("LoadPanelPartial")
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
        <script src="../../../../Scripts/json2.js" type="text/javascript"></script>  
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/jquery-ui-tabs.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/jquery-ui.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/PageCommon.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/CJL.0.1.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/ImagePreview.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

    new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
    )
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
    )

    <script>
     var documentCount=@documentCount;

    </script>

    <style type="text/css">
        .tdNoBorder
        {
            border-left: 0px;
            border-bottom: 0px;
        }
        .sywzClass
        {
            background-color: Red;
        }
    </style>

    <script>
        $(document).ready(function () {
            $("#tabs").css("display", "block");
            $("#tabs").tabs();
            $("#toolMenu").smartFloat();


            //            if ($("#hdMethod").val() != "EDIT") {
            //                var clientFDocClsCObj = ASPxClientTextBox.Cast("FDocClsCd");
            //                $(clientFDocClsCObj.GetInputElement()).blur(function () {
            //                    var docClsCd = $(this).val();
            //                    $.ajax({
            //                        type: "GET",
            //                        url: rootPath + "/Admin/DocumentCls/IsExistsDocClsCd",
            //                        data: { docClsCd: docClsCd },
            //                        success: function (result) {
            //                            if (result == "1") {
            //                                alert("类别编号已存在，请重新填写!");
            //                                clientFDocClsCObj.SetText("");
            //                            }
            //                        }
            //                    });
            //                });
            //            }


            var hdjsAlert = $("#hdjsAlert").val();
            if (hdjsAlert != "") {
                alert(hdjsAlert);
            }
        });
        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnSave":
                    {
                        //保存
                        save()
                        break;
                    }
                case "btnAddSame":
                    {
                        //增加同级
                        addSame();
                        break;
                    }
                case "btnAddNext":
                    {
                        //增加下级
                        addNext();
                        break;
                    }
                case "btnDelete":
                    {
                        //删除
                        deleteDocCls();
                        break;
                    }
                case "btnArch":
                    {
                        //归档
                        Archive();
                        break;
                    }
                case "btndelArch":
                    {
                        //归档
                        delArchive();
                        break;
                    }
            }
        }
        //取消归档
        function delArchive() {
            var FID = $('#hdFID').val();
            var FName = ASPxClientTextBox.Cast("FName").GetText();
            if (confirm("确定取消归档【" + FName + "】吗？")) {
                lpModal.Show();
                $.ajax({
                    type: "POST",
                    url: rootPath + "/Admin/EnterpriseFTP/DelArchive",
                    data: { FID: FID },
                    success: function (result) {
                        var msg = result.split('|');
                        if (msg[0] == "SUCCESS") {
                            alert("取消归档成功");
                            parent.afterDeleteNode();
                        }

                        else {

                            alert(msg[0]);

                        }
                    }
                });
                lpModal.Hide();
            }
        }
        //归档
        function Archive() {
            var FID = $('#hdFID').val();
            var FName = ASPxClientTextBox.Cast("FName").GetText();
            if (confirm("确定归档【" + FName + "】吗？")) {
                lpModal.Show();
                $.ajax({
                    type: "POST",
                    url: rootPath + "/Admin/EnterpriseFTP/SaveArchive",
                    data: { FID: FID },
                    success: function (result) {
                        var msg = result.split('|');
                        if (msg[0] == "SUCCESS") {
                            alert("归档成功");
                            parent.afterDeleteNode();
                        }
                       
                        else {
                           
                                alert(msg[0]);
                           
                        }
                    }
                });
                lpModal.Hide();
            }
        }
        /*增加同级*/
        function addSame() {
            var actionOP = 'ADD_SAME';
            var id = $('#hdFID').val();
            window.location.href = rootPath + "/Admin/EnterpriseFTP/EnterpriseFTP_NewEdit?FId=" + id + "&actionOP=" + actionOP;
        }
        /*增加下级*/
        function addNext() {
            var actionOP = 'ADD_NEXT';
            var id = $('#hdFID').val();
            window.location.href = rootPath + "/Admin/EnterpriseFTP/EnterpriseFTP_NewEdit?FId=" + id + "&actionOP=" + actionOP;
        }
        /*删除信息类别*/
        function deleteDocCls() {
            var FID = $('#hdFID').val();
            var FName = ASPxClientTextBox.Cast("FName").GetText();
            if (confirm("确定删除【" + FName + "】吗？")) {
                lpModal.Show();
                $.ajax({
                    type: "POST",
                    url: rootPath + "/Admin/EnterpriseFTP/DeleteFTP",
                    data: { FID: FID },
                    success: function (result) {
                        var msg = result.split('|');
                        if (msg[0] == "SUCCESS") {
                            alert("删除成功");
                            parent.afterDeleteNode();
                        }
                        else if (msg[0] == "EXISTCHILDFTP") {
                            alert("请先删除【" + FName + "】下的目录。");
                        }
                        else if (msg[0] == "EXISTFILE") {
                            alert("请先删除【" + FName + "】下的文件。");
                        }
                        else {
                            if (msg.length > 1) {
                                alert(msg[1]);
                            }
                        }
                    }
                });
                lpModal.Hide();
            }
        }

        /*保存*/
        function save() {
            var isCtlAllValid = true;
            var errorText = "";
            ASPxClientEdit.ValidateEditorsInContainer(null);
            var clientFNameObj = ASPxClientTextBox.Cast("FName");
            if (!clientFNameObj.GetIsValid()) {
                isCtlAllValid = false;
                errorText += clientFNameObj.GetErrorText() + "\n";
            }
            if (isCtlAllValid) {
                lpModal.Show();
                var pid = $("#hdFParentID").val();
                var FID = $('#hdFID').val();
                var FName = ASPxClientTextBox.Cast("FName").GetText();
                if ($("#hdMethod").val() == "EDIT") {
                    form1.submit();
                    lpModal.Hide();
                    return;

                }
            $.ajax({
                type: "POST",
                url: rootPath + "/Admin/EnterpriseFTP/ExistFTPFname",
                data: { FID: pid, FName: FName },
                success: function (result) {
                    if (result == "yes") {
                        alert("错误:已存在相同目录");
                        lpModal.Hide();
                    }
                    if (result == "no") {
                        form1.submit();
                        lpModal.Hide();
                    }
                }
            });

               
            }
            else {
                alert(errorText);
            }
        }

        //更改目录属性
        function ftpStatus_SelectedIndexChanged(s, e) {
            var clientftpStatusObj = ASPxClientComboBox.Cast("ftpStatus");
            var ftpStatus = clientftpStatusObj.GetValue();
            $('#hdftpStatus').val(ftpStatus);
        }
    </script>

</head>
@helper  ReturnBoolValue(string value)
    {
        if (value == "Y" || value == "AUDIT")
        {
    @:block
        }
        else
        {
    @:none
        }
}
<body>
    @using (Html.BeginForm("Save", "EnterpriseFTP", FormMethod.Post, new { id = "form1", enctype = "multipart/form-data", @class = "tableFrom" }))
    {
        <div class="floatToolMenu" id="toolMenu" style="z-index: 99;">
            <iframe style="position: absolute; visibility: inherit; top: 0px; left: 0px; width: 100%; height: 28px; z-index: -1; background-color: #00CCFF; border-width: 0px; filter='progid:dximagetransform.microsoft.alpha(style=0,opacity=0)';"></iframe>
            @Html.DevExpress().Menu(settings =>
       {
           settings.Name = "toolBarMenu";
           settings.ItemAutoWidth = false;
           settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
           settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
           settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
           settings.Items.Add(item =>
           {
               item.Name = "btnSave";
               item.Text = "保存";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/filesave.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnAddSame";
               item.Text = "增加同级";
               item.ClientEnabled = true;
               item.Visible = ViewData["hdMethod"].ToString() == "EDIT" ? true : false;
               item.Image.Url = Url.Content("~/Content/ControlImages/addSame.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnAddNext";
               item.Text = "增加下级";
               item.ClientEnabled = true;
               item.Visible = ViewData["hdMethod"].ToString() == "EDIT" ? true : false;
               item.Image.Url = Url.Content("~/Content/ControlImages/addNext.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnDelete";
               item.Text = "删除";
               item.ItemStyle.ForeColor = System.Drawing.Color.Red;
               item.ClientEnabled = true;
               item.Visible = ViewData["hdMethod"].ToString() == "EDIT" ? true : false;
               item.Image.Url = Url.Content("~/Content/ControlImages/cancel.png");

           });
          
               settings.Items.Add(item =>
               {
                   item.Name = "btnArch";
                   item.Text = "归档";
                   item.ItemStyle.ForeColor = System.Drawing.Color.Red;
                   item.ClientEnabled = true;
                   item.Visible = (bool)ViewData["arch"] & !(bool)ViewData["isarched"] & ViewData["hdMethod"].ToString() == "EDIT" ? true : false;
                   item.Image.Url = Url.Content("~/Content/ControlImages/business_contact.png");

               });
               settings.Items.Add(item =>
               {
                   item.Name = "btndelArch";
                   item.Text = "取消归档";
                   item.ItemStyle.ForeColor = System.Drawing.Color.Red;
                   item.ClientEnabled = true;
                   item.Visible = (bool)ViewData["arch"] & (bool)ViewData["isarched"] & ViewData["hdMethod"].ToString() =="EDIT"? true : false;
                   item.Image.Url = Url.Content("~/Content/ControlImages/business_contact.png");

               });
           settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
           settings.ItemLinkMode = ItemLinkMode.ContentBounds;
       }).GetHtml()
        </div>
        <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td style=" padding:100px 0px 0px 0px;">
                    <table align="center" class="tableFormNew" style=" width:400px;">
                        <tr>
                            <th style="width: 25%">
                                @Html.DevExpress().Label(settings => { settings.Text = "上级目录:"; }).GetHtml()
                            </th>
                            <td style="width: 75%" class="tdClass">
                                @Html.DevExpress().TextBox(settings =>
                           {
                               settings.Name = "FParentID";
                               settings.Width = 265;
                               settings.Enabled = false;
                           }).Bind(Model.strPreFTP).GetHtml()
               
                            </td>
                        </tr>
                        <tr>
                            <th style="width: 25%">
                                <font color='red'>*</font>@Html.DevExpress().Label(settings => { settings.Text = "目录名:"; }).GetHtml()
                            </th>
                            <td style="width: 75%" class="tdClass">
                                @Html.DevExpress().TextBox(settings =>
                           {
                               settings.Name = "FName";
                               settings.Width = 265;
                               settings.Properties.ClientSideEvents.Validation = "function(s,e){notEmptyValidation(s,e,'目录名')}";
                           }).Bind(Model.FName).GetHtml()
                            </td>
                        </tr>
                        <tr>
                            <th style="width: 25%">
                                <font color='red'>*</font>@Html.DevExpress().Label(settings => { settings.Text = "目录属性:"; }).GetHtml()
                            </th>
                            <td style="width: 75%" class="tdClass">
                                @Html.DevExpress().ComboBox(settings =>
                           {
                               settings.Name = "ftpStatus";
                               settings.Width = 265;
                               settings.Enabled = ViewData["canChangeStatus"] == null ? false : (bool)ViewData["canChangeStatus"];
                               settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                               settings.Properties.ClientSideEvents.SelectedIndexChanged = "function(s,e){ftpStatus_SelectedIndexChanged(s,e)}";
                           }).BindList(new List<SelectListItem> 
                                    { 
                                        new SelectListItem { Text = "上传", Value = "1" }, 
                                        new SelectListItem { Text = "下载", Value = "2" },
                                    }).Bind(Model.ftpStatus).GetHtml()
                        
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>

        @Html.Hidden("hdjsAlert", ViewData["jsAlert"]);//错误信息
        @Html.Hidden("hdMethod", ViewData["hdMethod"]);                                              
        @Html.Hidden("hdFID", Model.FID)
        @Html.Hidden("hdFParentID", Model.FParentID)
        @Html.Hidden("hdftpStatus", Model.ftpStatus)
        @Html.Hidden("harch", ViewData["isarched"])
    }
</body>
</html>

